﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;

using System.Web;
using System.Web.Routing;

namespace AL.Routing
{
    /// <summary>
    /// HH: 自定义区域子路由规则约束（如果是 HomeController, 并且 Action 为 HomeController 中的方法名 则返回匹配失败，不使用该路由规则）
    /// </summary>
    public class HHAreaRouteConstraint : IRouteConstraint
    {
        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            bool r = true;

            if (parameterName.ToLower() == "controller")
            {
                string ctrl = values["controller"].ToString();
                string act = values["action"].ToString();
                r = false;
                // 循环判定 controller 是否为 HomeController 中的 Aciton
                switch (ctrl.ToLower())
                {
                    default:
                        r = true;
                        break;

                    case "home": break;
                    case "login": break;
                    case "logout": break;
                    case "main": break;
                    case "getmenubar": break;
                    case "getusers": break;
                    case "getprovinces": break;
                    case "getcitys": break;
                    case "changepwd": break;
                    case "select": break;

                }

            }


            return r;

        }
    }
}
